import type { ConfigEnv } from 'vite'
import { loadEnv } from 'vite'
// import vue from '@vitejs/plugin-vue'
import alias from './vite/alias'
import { parseEnv } from './vite/util'
// import { plugin } from 'postcss'
import setupPlugins from './vite/plugins'

export default({command,mode}:ConfigEnv)=>{
  const isBuild = command == 'build'
  const root = process.cwd()
  const env = parseEnv(loadEnv(mode,root))
 
  return {
    // plugins: [vue()],
    plugins:setupPlugins(isBuild,env),
    base: './',
    resolve:{
      alias,
    },
    server: {
      proxy: { 
        '/api':{
          target: 'http://192.168.1.103:8086',
          changeOrigin: true,
          rewrite: (path:string) => path.replace(/^\/api/, '')
        }
      }
    }
   }
}